package badugajunit;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import badugabot.BotInfo;
import badugaclient.PlayerInfo;

public class ClientsBotsTest 
{
	private PlayerInfo p = new PlayerInfo();
	private BotInfo b = new BotInfo();
	
	@Before
	public void setUp() throws Exception
	{
		
	}

	@After
	public void tearDown() throws Exception
	{
		
	}
	
	@Test
	public void testSetAndGetHand()
	{
		p.setHand("0123456As2c3d4h");
		assertEquals("It's dying!", "As2c3d4h", p.getHand());
	}

	@Test
	public void testSetBotCardChange() 
	{
		b.setHand("0123456As2c3d4h");
		b.setBotCardChange();
		assertEquals("It's dying!", "FFFF", b.getCardsToChange());
		b.resetSelection();
		b.setHand("0123456As2s3s4s");
		b.setBotCardChange();
		assertEquals("It's dying!", "FTTT", b.getCardsToChange());
		b.resetSelection();
		b.setHand("01234568s8c9s9c");
		b.setBotCardChange();
		assertEquals("It's dying!", "TFFT", b.getCardsToChange());
		assertEquals("It's dying!", "FTTF", b.getCardsToChange());
		
	}

	@Test
	public void testToString() 
	{
		assertEquals("Ace of spades", p.toString("As"));
		assertEquals("10 of spades", p.toString("Ts"));
		assertEquals("Jack of hearts", p.toString("Jh"));
		assertEquals("Queen of diamonds", p.toString("Qd"));
		assertEquals("King of clubs", p.toString("Kc"));
		assertEquals("4 of spades", p.toString("4s"));
		assertEquals("9 of spades", p.toString("9s"));
	}

	@Test
	public void testDefaultState()
	{
		p.resetSelection();
		p.setBetRound("3");
		assertEquals("3", p.getBetRound());
		p.setCardsToChange("T", 3);
		assertEquals("FFFT", p.getCardsToChange());
		p.setBetted(false);
		assertEquals(false, p.isBetted());
		p.setRaised(true);
		assertEquals(true, p.isRaised());
		p.setCurrentTopBet("100");
		assertEquals(100, p.getCurrentTopBet());
		p.setMyBetInt("100");
		assertEquals(100, p.getMyBetInt());
		
		p.defaultState();
		assertEquals("0", p.getBetRound());
		assertEquals("", p.getCardsToChange());
		assertEquals(true, p.isBetted());
		assertEquals(false, p.isRaised());
		assertEquals(0, p.getCurrentTopBet());
		assertEquals(0, p.getMyBetInt());
	
	}

	@Test
	public void testGetHandForView()
	{
		p.setHand("0123456As2c3h4d");
		assertEquals("Ace of spades\n2 of clubs\n3 of hearts\n4 of diamonds\n", p.getHandForView());
	}

	@Test
	public void testGetCard() 
	{
		p.setHand("0123456As2c3d4h");
		assertNotEquals("2c", p.getCard(0));
		assertNotEquals("3d", p.getCard(1));
		assertNotEquals("4h", p.getCard(2));
		assertNotEquals("As", p.getCard(3));
	}

}
